package com.lastoffer2.adapter;

import com.lastoffer2.R;
import com.lastoffer2.activity.InsertOfferActivity;
import com.lastoffer2.activity.ListOfferActivity;
import com.lastoffer2.activity.ListOfferSuperUserActivity;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterMenuPrincipale extends BaseAdapter {

	private Context context;
	private String[] items;
	private LayoutInflater layoutInflater;

	public AdapterMenuPrincipale(Context context) {
		this.context = context;
		Resources res = context.getResources();
		items = res.getStringArray(R.array.main_menu_item);
		layoutInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return items[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder holder;
		if (convertView == null) {
			convertView = layoutInflater.inflate(R.layout.item_main_menu, null);
			
			holder = new ViewHolder();
			holder.TextViewDescrizione = (TextView) convertView.findViewById(R.id.descrizioneItemMenuPrincipale);
			holder.TextViewNumeroOfferte = (TextView) convertView.findViewById(R.id.TextViewNumeroOfferte);
			holder.TextView03 = (TextView) convertView.findViewById(R.id.TextView03);
			
			holder.imageViewCategoriaOfferte = (ImageView) convertView.findViewById(R.id.imageViewCategoriaOfferte);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.TextViewDescrizione.setText(items[position]);
		holder.imageViewCategoriaOfferte.setImageResource(R.drawable.palla);
		switch (position) {
		case 0://Ristoranti
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.piatto);
			break;
		case 1://Aperitivi
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.drink);
			break;
		case 2:// <item>Cinema</item>      
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.cinema);
			break;
		case 3://eventi
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.palla);
			break;
		case 4://cose
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.cose);
			break;
		case 5://Le tue prenotazioni
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.prenotazioni2);
			break;
		case 6: //Crea offerta
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.prenotazioni);
			break;
		case 7://Le tue offerte
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.offerte);
			break;
		case 8://settings
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.settings);
			break;

		default:
			holder.imageViewCategoriaOfferte.setImageResource(R.drawable.palla);
			break;
		}
		convertView.setTag(holder);
		return convertView;
	}
	static class ViewHolder {

		public TextView TextView03;
		public TextView TextViewDescrizione;
		public ImageView imageViewCategoriaOfferte;
		public TextView TextViewNumeroOfferte;
	
	}

}
